package org.setamv.springcloud.feignclient;

import org.setamv.springcloud.entity.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.List;

/**
 * 定义访问User服务访问失败的回退类。对应Hystrix的fallback方法
 */
@Component
public class UserServiceFallbackClient implements UserServiceClient {

    public User getUser(String id) {
        return new User(id, "fallback", null);
    }

    public User getUserSlowly(String id) {
        return new User(id, "fallback", null);
    }

    public List<User> getUsers(String ids) {
        return new ArrayList<>();
    }

    public User echoByJson(User user) {
        user.setName("fallback");
        return user;
    }

    public User echoByXml(User user) {
        user.setName("fallback");
        return user;
    }
}
